<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- /fasttmp/mkdist-qt-4.3.5-1211793125/qtopia-core-opensource-src-4.3.5/src/gui/itemviews/qstringlistmodel.cpp -->
<head>
  <title>Qt 4.3: QStringListModel Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QStringListModel Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1>
<p>The QStringListModel class provides a model that supplies strings to views. <a href="#details">More...</a></p>
<pre> #include &lt;QStringListModel&gt;</pre><p>Inherits <a href="qabstractlistmodel.html">QAbstractListModel</a>.</p>
<ul>
<li><a href="qstringlistmodel-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h3>Public Functions</h3>
<ul>
<li><div class="fn"/><b><a href="qstringlistmodel.html#QStringListModel">QStringListModel</a></b> ( QObject * <i>parent</i> = 0 )</li>
<li><div class="fn"/><b><a href="qstringlistmodel.html#QStringListModel-2">QStringListModel</a></b> ( const QStringList &amp; <i>strings</i>, QObject * <i>parent</i> = 0 )</li>
<li><div class="fn"/>virtual QVariant <b><a href="qstringlistmodel.html#data">data</a></b> ( const QModelIndex &amp; <i>index</i>, int <i>role</i> ) const</li>
<li><div class="fn"/>virtual Qt::ItemFlags <b><a href="qstringlistmodel.html#flags">flags</a></b> ( const QModelIndex &amp; <i>index</i> ) const</li>
<li><div class="fn"/>virtual bool <b><a href="qstringlistmodel.html#insertRows">insertRows</a></b> ( int <i>row</i>, int <i>count</i>, const QModelIndex &amp; <i>parent</i> = QModelIndex() )</li>
<li><div class="fn"/>virtual bool <b><a href="qstringlistmodel.html#removeRows">removeRows</a></b> ( int <i>row</i>, int <i>count</i>, const QModelIndex &amp; <i>parent</i> = QModelIndex() )</li>
<li><div class="fn"/>virtual int <b><a href="qstringlistmodel.html#rowCount">rowCount</a></b> ( const QModelIndex &amp; <i>parent</i> = QModelIndex() ) const</li>
<li><div class="fn"/>virtual bool <b><a href="qstringlistmodel.html#setData">setData</a></b> ( const QModelIndex &amp; <i>index</i>, const QVariant &amp; <i>value</i>, int <i>role</i> = Qt::EditRole )</li>
<li><div class="fn"/>void <b><a href="qstringlistmodel.html#setStringList">setStringList</a></b> ( const QStringList &amp; <i>strings</i> )</li>
<li><div class="fn"/>QStringList <b><a href="qstringlistmodel.html#stringList">stringList</a></b> () const</li>
</ul>
<ul>
<li><div class="fn"/>1 public function inherited from <a href="qabstractlistmodel.html#public-functions">QAbstractListModel</a></li>
<li><div class="fn"/>34 public functions inherited from <a href="qabstractitemmodel.html#public-functions">QAbstractItemModel</a></li>
<li><div class="fn"/>29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li><div class="fn"/>2 public slots inherited from <a href="qabstractitemmodel.html#public-slots">QAbstractItemModel</a></li>
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li><div class="fn"/>14 signals inherited from <a href="qabstractitemmodel.html#signals">QAbstractItemModel</a></li>
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
<li><div class="fn"/>5 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li><div class="fn"/>14 protected functions inherited from <a href="qabstractitemmodel.html#protected-functions">QAbstractItemModel</a></li>
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The QStringListModel class provides a model that supplies strings to views.</p>
<p>QStringListModel is an editable model that can be used for simple cases where you need to display a number of strings in a view widget, such as a <a href="qlistview.html">QListView</a> or a <a href="qcombobox.html">QComboBox</a>.</p>
<p>The model provides all the standard functions of an editable model, representing the data in the string list as a model with one column and a number of rows equal to the number of items in the list.</p>
<p>Model indexes corresponding to items are obtained with the <a href="qabstractlistmodel.html#index">index()</a> function, and item flags are obtained with <a href="qstringlistmodel.html#flags">flags</a>(). Item data is read with the <a href="qstringlistmodel.html#data">data</a>() function and written with <a href="qstringlistmodel.html#setData">setData</a>(). The number of rows (and number of items in the string list) can be found with the <a href="qstringlistmodel.html#rowCount">rowCount</a>() function.</p>
<p>The model can be constructed with an existing string list, or strings can be set later with the <a href="qstringlistmodel.html#setStringList">setStringList</a>() convenience function. Strings can also be inserted in the usual way with the <a href="qstringlistmodel.html#insertRows">insertRows</a>() function, and removed with <a href="qstringlistmodel.html#removeRows">removeRows</a>(). The contents of the string list can be retrieved with the <a href="qstringlistmodel.html#stringList">stringList</a>() convenience function.</p>
<p>An example usage of QStringListModel:</p>
<pre>     QStringListModel *model = new QStringListModel();
     QStringList list;
     list &lt;&lt; &quot;a&quot; &lt;&lt; &quot;b&quot; &lt;&lt; &quot;c&quot;;
     model-&gt;setStringList(list);</pre>
<p>See also <a href="qabstractlistmodel.html">QAbstractListModel</a>, <a href="qabstractitemmodel.html">QAbstractItemModel</a>, and <a href="model-view-model.html">Model Classes</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<h3 class="fn"><a name="QStringListModel"></a>QStringListModel::QStringListModel ( <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a string list model with the given <i>parent</i>.</p>
<h3 class="fn"><a name="QStringListModel-2"></a>QStringListModel::QStringListModel ( const <a href="qstringlist.html">QStringList</a> &amp; <i>strings</i>, <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
<p>Constructs a string list model containing the specified <i>strings</i> with the given <i>parent</i>.</p>
<h3 class="fn"><a name="data"></a><a href="qvariant.html">QVariant</a> QStringListModel::data ( const <a href="qmodelindex.html">QModelIndex</a> &amp; <i>index</i>, int <i>role</i> ) const&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Returns data for the specified <i>role</i>, from the item with the given <i>index</i>.</p>
<p>If the view requests an invalid index, an invalid variant is returned.</p>
<p>Reimplemented from <a href="qabstractitemmodel.html#data">QAbstractItemModel</a>.</p>
<p>See also <a href="qstringlistmodel.html#setData">setData</a>().</p>
<h3 class="fn"><a name="flags"></a><a href="qt.html#ItemFlag-enum">Qt::ItemFlags</a> QStringListModel::flags ( const <a href="qmodelindex.html">QModelIndex</a> &amp; <i>index</i> ) const&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Returns the flags for the item with the given <i>index</i>.</p>
<p>Valid items are enabled, selectable, and editable.</p>
<p>Reimplemented from <a href="qabstractitemmodel.html#flags">QAbstractItemModel</a>.</p>
<p>See also <a href="qabstractitemmodel.html#flags">QAbstractItemModel::flags</a>().</p>
<h3 class="fn"><a name="insertRows"></a>bool QStringListModel::insertRows ( int <i>row</i>, int <i>count</i>, const <a href="qmodelindex.html">QModelIndex</a> &amp; <i>parent</i> = QModelIndex() )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Inserts <i>count</i> rows into the model, beginning at the given <i>row</i>.</p>
<p>The <i>parent</i> index of the rows is optional and is only used for consistency with <a href="qabstractitemmodel.html">QAbstractItemModel</a>. By default, a null index is specified, indicating that the rows are inserted in the top level of the model.</p>
<p>Reimplemented from <a href="qabstractitemmodel.html#insertRows">QAbstractItemModel</a>.</p>
<p>See also <a href="qabstractitemmodel.html#insertRows">QAbstractItemModel::insertRows</a>().</p>
<h3 class="fn"><a name="removeRows"></a>bool QStringListModel::removeRows ( int <i>row</i>, int <i>count</i>, const <a href="qmodelindex.html">QModelIndex</a> &amp; <i>parent</i> = QModelIndex() )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Removes <i>count</i> rows from the model, beginning at the given <i>row</i>.</p>
<p>The <i>parent</i> index of the rows is optional and is only used for consistency with <a href="qabstractitemmodel.html">QAbstractItemModel</a>. By default, a null index is specified, indicating that the rows are removed in the top level of the model.</p>
<p>Reimplemented from <a href="qabstractitemmodel.html#removeRows">QAbstractItemModel</a>.</p>
<p>See also <a href="qabstractitemmodel.html#removeRows">QAbstractItemModel::removeRows</a>().</p>
<h3 class="fn"><a name="rowCount"></a>int QStringListModel::rowCount ( const <a href="qmodelindex.html">QModelIndex</a> &amp; <i>parent</i> = QModelIndex() ) const&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Returns the number of rows in the model. This value corresponds to the number of items in the model's internal string list.</p>
<p>The optional <i>parent</i> argument is in most models used to specify the parent of the rows to be counted. Because this is a list if a valid parent is specified, the result will always be 0.</p>
<p>Reimplemented from <a href="qabstractitemmodel.html#rowCount">QAbstractItemModel</a>.</p>
<p>See also <a href="qstringlistmodel.html#insertRows">insertRows</a>(), <a href="qstringlistmodel.html#removeRows">removeRows</a>(), and <a href="qabstractitemmodel.html#rowCount">QAbstractItemModel::rowCount</a>().</p>
<h3 class="fn"><a name="setData"></a>bool QStringListModel::setData ( const <a href="qmodelindex.html">QModelIndex</a> &amp; <i>index</i>, const <a href="qvariant.html">QVariant</a> &amp; <i>value</i>, int <i>role</i> = Qt::EditRole )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Sets the data for the specified <i>role</i> in the item with the given <i>index</i> in the model, to the provided <i>value</i>.</p>
<p>The <a href="qabstractitemmodel.html#dataChanged">dataChanged</a>() signal is emitted if the item is changed.</p>
<p>Reimplemented from <a href="qabstractitemmodel.html#setData">QAbstractItemModel</a>.</p>
<p>See also <a href="qt.html#ItemDataRole-enum">Qt::ItemDataRole</a> and <a href="qstringlistmodel.html#data">data</a>().</p>
<h3 class="fn"><a name="setStringList"></a>void QStringListModel::setStringList ( const <a href="qstringlist.html">QStringList</a> &amp; <i>strings</i> )</h3>
<p>Sets the model's internal string list to <i>strings</i>. The model will notify any attached views that its underlying data has changed.</p>
<p>See also <a href="qstringlistmodel.html#stringList">stringList</a>() and <a href="qabstractitemmodel.html#dataChanged">dataChanged</a>().</p>
<h3 class="fn"><a name="stringList"></a><a href="qstringlist.html">QStringList</a> QStringListModel::stringList () const</h3>
<p>Returns the string list used by the model to store data.</p>
<p>See also <a href="qstringlistmodel.html#setStringList">setStringList</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.5</div></td>
</tr></table></div></address></body>
</html>
